:root {
  --size-scrollbar: 12px;
  --theme-background: white;
  --theme-foreground: black;
  --theme-secondary-foreground: #777;
  --theme-bar-background: #f1f1f1;
  --theme-border: gainsboro;
  --theme-handler: grey;
  --theme-hover-background: rgba(0, 0, 0, 0.05);
  --theme-linenumbers: #959da5;
  --theme-selected-background: linen;
  --theme-code-foreground: #333;
  --theme-keywords: #e53;
  --theme-numbers: var(--theme-variables);
  --theme-variables: #248;
  --theme-builtins: #000;
  --theme-operators: #872;
  --theme-comments: #666;
  --theme-box-shadow: rgba(180, 180, 180, 0.38);
}

body.dark-theme {
  --theme-background: #111;
  --theme-foreground: #eee;
  --theme-secondary-foreground: #888;
  --theme-bar-background: #181818;
  --theme-border: #333;
  --theme-handler: grey;
  --theme-hover-background: rgba(0, 0, 0, 0.05);
  --theme-linenumbers: #888;
  --theme-selected-background: #333;
  --theme-code-foreground: #ddd;
  --theme-keywords: #e53;
  --theme-variables: #248;
  --theme-builtins: #ddd;
  --theme-operators: #872;
  --theme-comments: #666;
  --theme-box-shadow: rgba(0, 0, 0, 0.38);
}

body,
#out-iframe,
#out-outer,
#out-render {
  background: var(--theme-background);
  color: var(--theme-foreground);
}

.embed #hand-ex,
.embed:not(.show-configs) #setting-button,
.embed:not(.show-compile) #hand-v,
.embed:not(.show-compile) #js-outer,
.embed:not(.show-compile) #compile,
.embed:not(.show-output) #hand-h,
.embed:not(.show-output) #out-outer,
.embed:not(.show-output) #out,
.embed:not(.show-bars) .bar,
.embed .hide-embed {
  display: none !important;
}

#in-outer,
#js-outer,
#ex-outer {
  position: absolute;
}

#out-outer {
  position: absolute;
  overflow: hidden;
  font-size: 13px;
}

#in,
#js,
#out-iframe,
#explorer {
  width: 100%;
  height: calc(100% - 35px);
  overflow: auto;
}

.bar {
  height: 20px;
  padding: 7px 10px;
  border-bottom: 1px solid;
  z-index: 1000;
  font-size: 15px;
  overflow: visible;
  white-space: nowrap;
}

.bar * {
  vertical-align: middle;
}

.bar .title {
  display: inline-block;
  margin: 0 5px;
  padding: 0 5px;
  line-height: 22px;
  cursor: default;
  color: var(--theme-secondary-foreground);
}

.bar .subtitle {
  display: inline-block;
  padding: 0 5px;
  margin-left: -5px;
  margin-right: 5px;
  line-height: 22px;
  font-size: 0.9em;
  font-style: italic;
  cursor: default;
  color: var(--theme-secondary-foreground);
  opacity: 0.7;
}

.bar .right-aligned {
  position: absolute;
  top: 0px;
  right: 0;
  padding: 7px;
  display: inline-block;
  height: 20px;
  border-bottom: 1px solid;
  border-left: 1px solid;
}

.bar,
.bar .right-aligned {
  background: var(--theme-bar-background);
  border-color: var(--theme-border);
}

body:not(.readonly) #in-bar .title,
body:not(.readonly) #in-bar .subtitle {
  cursor: text;
  border-radius: 3px;
}

body:not(.readonly) #in-bar .title:hover,
body:not(.readonly) #in-bar .subtitle:hover {
  background: var(--theme-hover-background);
}

#current-file-name {
  color: var(--theme-foreground);
}

#out-iframe {
  border: none;
  position: fixed;
  margin: 0px;
  overflow: auto;
  font-family: monospace;
  z-index: -2;
}

#out-render {
  position: absolute;
  padding: 10px;
  margin: 0px;
  top: 36px;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: auto;
  width: auto;
  height: auto;
}

#hand-v,
#hand-ex {
  position: absolute;
  cursor: ew-resize;
  z-index: 100;
}

.editor-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -2;
  padding: 3px 6px;
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
  font-style: italic;
  background: var(--theme-bar-background);
  color: var(--theme-secondary-foreground);
}

#hand-h {
  position: absolute;
  cursor: ns-resize;
  z-index: 100;
}

#hand-v-inner,
#hand-ex-inner {
  border-left: 1px solid;
  border-right: 1px solid;
  height: 100%;
  margin: 0px 3px 3px 3px;
  opacity: 0.8;
}

#hand-h-inner {
  border-top: 1px solid;
  border-bottom: 1px solid;
  margin: 4px 0px 4px 0px;
  width: 100%;
  height: 1px;
  opacity: 0.8;
}

#hand-v-inner,
#hand-ex-inner,
#hand-h-inner {
  border-color: var(--theme-handler);
  background: var(--theme-background);
}

#explorer {
  background: var(--theme-background);
}

.caret {
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  opacity: 0.5;
}

.caret::before {
  font-size: 10px;
  content: "\25B6";
  color: var(--theme-foreground);
  display: inline-block;
  margin-left: 8px;
  margin-right: 4px;
  opacity: 0.5;
  transform: scaleX(0.8) translateY(-2px);
}

.caret.active {
  padding-bottom: 10px;
}

.caret.active::before {
  transform: scaleY(0.8) translateY(-2px) rotate(90deg);
}

ul.nested {
  display: none;
  padding: 5px 0;
}

ul.nested.active {
  display: block;
}

#explorer-list {
  margin: 0;
  padding: 8px 0;
}

#explorer-list li,
#explorer-list ul {
  list-style: none;
}

#explorer-list li {
  padding: 0;
  margin: 0;
  font-size: 13px;
  font-family: sans-serif;
  padding: 3px 0;
  white-space: nowrap;
  cursor: pointer;
}

#explorer-list ul.nested li {
  padding: 3px 5px 3px 20px;
}

#explorer-list ul.nested li:hover {
  background: var(--theme-bar-background);
}

#explorer-list ul.nested li.active {
  background: var(--theme-selected-background);
  font-weight: bold;
}

#explorer-list ul.nested li .name {
  padding-right: 5px;
}

#explorer-list ul.nested li .alias {
  opacity: 0.5;
}

.panel {
  background: var(--theme-background);
  border: 1px solid var(--theme-border);
  box-shadow: 2px 2px 11px 0px var(--theme-box-shadow);
  border-radius: 3px;
  padding: 16px 14px;
}

.panel > * {
  vertical-align: middle;
}

.panel .title {
  opacity: 0.5;
  font-size: 1.1em;
  padding: 0 5px;
}

.panel .subtitle {
  opacity: 0.5;
  font-size: 0.8em;
  padding: 10px 5px 3px 5px;
}

.panel .section {
  font-size: 0.9em;
  padding: 5px 5px;
}

.panel .details {
  padding: 5px 5px;
  font-style: italic;
  font-size: 0.85em;
  opacity: 0.6;
}

.panel .close {
  position: absolute;
  right: 5px;
  top: 8px;
}

.panel button.dropdown {
  margin-top: 2px;
  margin-bottom: 5px;
}

.panel button.checkbox {
  padding: 0;
  margin: 3px 0 3px 4px;
}

#help-panel {
  position: fixed;
  top: 35px;
  right: 45px;
  width: 300px;
  z-index: 1000;
}

#setting-panel {
  position: fixed;
  top: 35px;
  right: 10px;
  width: 300px;
  z-index: 1000;
}

#package-info-panel {
  position: fixed;
  width: 400px;
  top: 50vh;
  left: calc(50vw - 150px);
  transform: translateY(-50%);
  z-index: 1000;
}

#shortcut-table {
  font-size: 0.9em;
  padding: 4px;
  margin-bottom: 5px;
  width: 100%;
}

#shortcut-table td {
  padding: 5px 0;
}

#shortcut-table td:first-child {
  opacity: 0.8;
}

button {
  background: var(--theme-background);
  border: 1px solid var(--theme-border);
  color: var(--theme-foreground);
  border-radius: 3px;
  margin: 0 3px;
  height: 22px;
}

button:hover {
  background: var(--theme-border);
  border: 1px solid var(--theme-secondary-foreground);
}

button:active {
  background: var(--theme-secondary-foreground);
}

button:focus {
  outline: none;
}

button.icon {
  padding: 0;
  text-align: center;
  width: 26px;
  font-size: 18px;
  line-height: 18px;
  cursor: pointer;
}

button.icon > svg {
  margin-top: -0.2rem;
}

button.icon * {
  vertical-align: middle;
}

button.checkbox {
  border: none;
  background: none;
  cursor: pointer;
  margin-top: 0.15rem;
}
button.checkbox label {
  font-size: 1.1em;
  margin-left: 0.2rem;
}
button.checkbox * {
  line-height: 100%;
  vertical-align: middle;
}
button.checkbox .iconify {
  border: 1px solid var(--theme-border);
  border-radius: 3px;
  height: 16px;
  width: 16px;
  margin-bottom: 1px;
  background: var(--theme-background);
}
button.checkbox:hover .iconify {
  border: 1px solid grey;
  background: var(--theme-border);
}
button.checkbox:not(.checked) .iconify {
  color: transparent;
}

button.dropdown {
  position: relative;
  user-select: none;
  padding-left: 10px;
}

button.dropdown select {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: -4;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: pointer;
}

button.dropdown label {
  border-right: 1px solid var(--theme-border);
  height: 100%;
  margin: -5px 0 -5px -3px;
  padding-right: 6px;
  margin-right: 3px;
  width: 16px;
}

button.dropdown .iconify {
  margin-left: -2px;
}

button.dropdown:hover label {
  border-right: 1px solid var(--theme-secondary-foreground);
}
button[disabled] {
  opacity: 0.8;
  pointer-events: none;
}

.hidden {
  display: none !important;
  pointer-events: none !important;
}

.show-invisibles .cm-tab {
  background: url();
  background-position: right;
  background-repeat: no-repeat;
}

/* ===== Scrollbar ====== */
::-webkit-scrollbar {
  width: var(--size-scrollbar);
  background-color: var(--theme-background);
}
::-webkit-scrollbar-thumb {
  width: var(--size-scrollbar);
  background-color: var(--theme-border);
  opacity: 0.6;
}
::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:focus {
  background-color: var(--theme-selected-background);
  opacity: 1;
}
::-webkit-scrollbar-thumb:active {
  background-color: var(--theme-handler);
  opacity: 1;
}
::-webkit-scrollbar-corner {
  background-color: var(--theme-background);
}
.CodeMirror-hscrollbar {
  height: var(--size-scrollbar);
  outline: none;
}
.CodeMirror-vscrollbar {
  width: var(--size-scrollbar);
  outline: none;
}
.CodeMirror-scrollbar-filler {
  background-color: var(--theme-background);
}

/* ===== Tooltips ====== */

/* Add this attribute to the element that needs a tooltip */
[data-tooltip] {
  position: relative;
  cursor: pointer;
}

/* Hide the tooltip content by default */
[data-tooltip]:before,
[data-tooltip]:after {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

/* Position tooltip above the element */
[data-tooltip]:before {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 5px;
  padding: 2px 6px;
  width: auto;
  font-size: 0.75em;
  transform: translateX(-50%);
  border-radius: 3px;
  border: 1px solid var(--theme-border);
  background-color: var(--theme-background);
  color: var(--theme-foreground);
  content: attr(data-tooltip);
  text-align: center;
  z-index: 1000;
}

/* Show tooltip content on hover */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
  visibility: visible;
  opacity: 1;
}

/* ===== Code Mirror ===== */

.cm-s-wenyan-light.CodeMirror {
  background: var(--theme-background);
  color: var(--theme-code-foreground);
  line-height: 120%;
}
.cm-s-wenyan-light .CodeMirror-gutters {
  background: var(--theme-bar-background);
  border-right-width: 0;
}
.cm-s-wenyan-light .CodeMirror-guttermarker {
  color: var(--theme-background);
}
.cm-s-wenyan-light .CodeMirror-guttermarker-subtle {
  color: var(--theme-secondary-foreground);
}
.cm-s-wenyan-light .CodeMirror-linenumber {
  color: var(--theme-linenumbers);
  padding: 0 3px 0 3px;
}
.cm-s-wenyan-light .CodeMirror-cursor {
  border-left: 1px solid var(--theme-foreground);
}
.cm-s-wenyan-light div.CodeMirror-selected {
  background: var(--theme-selected-background);
}
.cm-s-wenyan-light div.CodeMirror-activeline-background {
  background: var(--theme-selected-background);
}
.cm-s-wenyan-light .cm-comment {
  color: var(--theme-comments);
}
.cm-s-wenyan-light .cm-keyword {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-keywords);
}
.cm-s-wenyan-light .cm-number {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-numbers);
}
.cm-s-wenyan-light .cm-string {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-variables);
}
.cm-s-wenyan-light .cm-variable,
.cm-s-wenyan-light .cm-variable-2,
.cm-s-wenyan-light .cm-def {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-variables);
}
.cm-s-wenyan-light .cm-atom {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-builtins);
}
.cm-s-wenyan-light .cm-type {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-variables);
}
.cm-s-wenyan-light .cm-builtin {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-builtins);
}
.cm-s-wenyan-light .cm-operator {
  font-weight: normal;
  font-style: normal;
  text-decoration: none;
  color: var(--theme-operators);
}
